# coding=utf-8
import maya.cmds as cmds
import logging
logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')

def Win():
	windowName = u'模型形状混合' 
	if cmds.window (windowName,ex = 1):
		cmds.deleteUI (windowName)
	window  = cmds.window (windowName,sizeable = 0,widthHeight=	(300, 50))
	cmds.rowLayout( numberOfColumns=2)
	cmds.button(u"混合形状",h=50,w=150,c =lambda *args: _blendShape() )
	cmds.setParent( '..' )
	cmds.showWindow(window)
def _blendShape():	
	selectObjs = cmds.ls(sl = 1)
	ObjHistory =  cmds.listHistory( selectObjs[1] ,levels=1)#,future=True
	for i in ObjHistory:
		if "blendShape" in i:
			logger = logging.getLogger(selectObjs[1])
			return(logger.error(u'已经存在blendShape阶段，无法进行混合-请检查文件'))
	ObjblendShape = cmds.blendShape(selectObjs[0],selectObjs[1], n =selectObjs[0] + "_blendShape")
	cmds.setAttr (ObjblendShape[0]+"." + selectObjs[0] , 1)
	